import os
basedir = os.path.abspath(os.path.dirname(__file__))


class Config:
	SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
	SQLALCHEMY_COMMIT_ON_TEARDOWN = True
	SQLALCHEMY_TRACK_MODIFICATIONS = False
	Second = 1
	Minute = 60
	Hour = 3600
	# api_prefix
	API_PREFIX = '/api/v1'
	# wx
	SERVER_ACCESS_TOKEN_URL = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s'
	UPLOAD_UI_URL = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=%s'
	WEB_ACCESS_TOKEN_URL = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code'
	# USER_INFO_URL = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token=%s&openid=%s&lang=zh_CN'
	USER_INFO_URL = 'https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN'
	EncodingAESKey = 'nkEWqxzrb3ZzzB8A51nf50d1PjlC6lveR51oybmQh7W'
	JSAPI_TICKET_URL = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi'
	# pingpp
	PING_APP_ID = 'app_rnnvTOev9uPOT4Wv'
	@staticmethod
	def init_app(app):
		pass


class DevelopmentConfig(Config):
	DEBUG = True
	#wx
	APPID = 'wxc565e7bec6ef35d8'
	APPSECRET = 'f698276d9f6a91fe7f5c52a30e2e4f4b'
	#redis
	REDIS_URL = "redis://:ztxtztxt123@39.108.104.219:6379/1"
	REDIS_KEY_PREFIX = 'wx_dev_'
	REDIS_DEFAULT_EXPIRE = 1*60*2
	REDIS_USER_EXPIRE = 60 * 60 * 24
	#pingxx
	PING_PRIVATE_KEY_PATH = os.path.join('resource', 'dev', 'pingpp_private_key.pem')
	PING_API_KEY = 'sk_test_OOqLW1fTeTmLDWLSiH9eTaz9'
	# MySQL
	SQLALCHEMY_DATABASE_URI = "mysql+pymysql://bbkb:Ztxtztxt123@rm-wz95g4n8212p9cld3o.mysql.rds.aliyuncs.com:3306/baby_insurance"


class TestingConfig(Config):
	DEBUG = False
	#wx
	APPID = 'wx35b7b0b8dee94c86'
	APPSECRET = '12494ef816e55256be24d0e80237d247'
	#redis
	REDIS_URL = "redis://:ztxtztxt123@39.108.104.219:6379/2"
	REDIS_KEY_PREFIX = 'wx_test_'
	REDIS_DEFAULT_EXPIRE = 1*60*2
	REDIS_USER_EXPIRE = 60 * 60 * 24
	#pingxx
	PING_PRIVATE_KEY_PATH = 'C:\workspace\py\wx_server_prototype\\resource\dev\pingpp_private_key.pem'
	PING_API_KEY = 'sk_live_8i9Ca9mDyLS4ez9y5K8qbTy9'
	PING_PAY_CALLBACK_URL = 'http://192.168.3.100:9020/pay/callback'


class ProductionConfig(Config):
	DEBUG = False
	#wx
	APPID = 'wx35b7b0b8dee94c86'
	APPSECRET = '12494ef816e55256be24d0e80237d247'
	#redis
	REDIS_URL = "redis://:ztxtztxt123@39.108.104.219:6379/0"
	REDIS_KEY_PREFIX = 'wx_prod_'
	REDIS_DEFAULT_EXPIRE = 1*60*2
	REDIS_USER_EXPIRE = 60 * 60 * 24
	#pingxx
	PING_PRIVATE_KEY_PATH = './resource/prod/pingpp_private_key.pem'
	PING_API_KEY = 'sk_live_8i9Ca9mDyLS4ez9y5K8qbTy9'
	PING_PAY_CALLBACK_URL = 'http://172.18.196.198:9020/pay/callback'

config = {
    'development': DevelopmentConfig,
    'testing': TestingConfig,
    'production': ProductionConfig,

    'default': DevelopmentConfig
}
